//package com.zmn.plat.dubbo.impl.product.graphic;
//
//import com.alibaba.fastjson.JSONObject;
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.collection.CollectionUtil;
//import com.zmn.common.utils.reflect.BeanMapper;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.business.interfaces.product.ProductCache;
//import com.zmn.plat.common.dictionary.PlatErrorCodeDict;
//import com.zmn.plat.common.dto.product.graphic.ProductGraphicDRO;
//import com.zmn.plat.dubbo.interfaces.product.graphic.GraphisListRemotService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.product.graphic.ProductGraphic;
//import com.zmn.plat.model.entity.product.graphic.ProductGraphicQuery;
//import com.zmn.plat.model.vo.product.ProductAllMsgVO;
//import com.zmn.plat.services.interfaces.product.graphic.ProductGraphicService;
//import com.zmn.plat.utils.bean.BeanCopyUtils;
//import io.swagger.annotations.Api;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.dubbo.config.annotation.Service;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.Optional;
//import java.util.stream.Collectors;
//
//
///**
// * 类描述：前台产品-图文信息
// *
// * @author yangshuangping
// * @since 2021/12/14 9:34
// */
//@Slf4j
//@Api(value = "前台产品关联图文信息远程api", tags = {"前台产品关联图文信息"})
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class GraphisListRemotServiceImpl implements GraphisListRemotService {
//
//    private static final String TAG = "前台产品-图文信息";
//
//    @Resource
//    private ProductGraphicService productGraphicService;
//
//    @Resource
//    ProductCache productCache;
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ProductGraphicDRO>> listByProductIds(List<Integer> productIds) {
//
//        log.info("{}#GraphisListRemotService# method：listByProductIds param :[{}]", TAG, JSONObject.toJSONString(productIds));
//
//        if (CollectionUtil.isNullOrEmpty(productIds)) {
//            log.error("{}#GraphisListRemotService# method：listByProductIds param is null", TAG);
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PANAM_NULL);
//        }
//        productIds = productIds.stream().distinct().collect(Collectors.toList());
//        // 根据产品id获取对应的服务分类，产品分类
//        final List<ProductAllMsgVO> listProduct = productCache.listByKeys(productIds);
//        if (CollectionUtil.isNullOrEmpty(listProduct)) {
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_RESULT_NULL);
//        }
//        Map<Integer, ProductAllMsgVO> map = listProduct.stream()
//                .collect(Collectors.toMap(x -> x.getProductId(), (x) -> x));
//
//        ProductGraphicQuery query = new ProductGraphicQuery();
//        query.setProductIds(productIds);
//        query.setStatus(GlobalConsts.YES);
//        final List<ProductGraphic> listGraphic = productGraphicService.listByQuery(query);
//        try {
//            List<ProductGraphicDRO> listProductGraphic = new ArrayList<>(listGraphic.size());
//            listGraphic.forEach(productGraphic -> {
//                ProductGraphicDRO graphicDRO = BeanMapper.map(productGraphic, ProductGraphicDRO.class);
//                ProductAllMsgVO product = Optional.ofNullable(
//                                map.get(productGraphic.getProductId()))
//                        .orElse(new ProductAllMsgVO());
//                BeanCopyUtils.copyProperties(product, graphicDRO);
//                graphicDRO.setProductName(product.getName());
//                listProductGraphic.add(graphicDRO);
//            });
//            log.info("{}#GraphisListRemotService# method：listByProductIds data: data query successful", TAG);
//            return ResponseDTO.success(listProductGraphic, "操作成功！");
//        } catch (Exception e) {
//            log.error("{}#GraphisListRemotService# method：listByProductIds data : dataConversionException", TAG, e);
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_THIRD_SERVICE_ERROR);
//        }
//    }
//}
